package com.ynwa.thread.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author gzd
 * @date 2018-07-18 下午 5:00
 * @desc 固定大小线程数量的线程池demo
 */
public class FixedThreadPoolDemo {

    private static Runnable runnable = () -> {
        System.out.println("当前线程是：" + Thread.currentThread().getName());
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    };

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(5);
        for (int i = 0; i < 10; i++) {
            executorService.submit(runnable);
        }
    }
}
